package com.wisdom.smartbook.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import com.wisdom.smartbook.R;


/**
 * 显示dialog工具类
 */
public class DialogTipsUtil {


    public static void notLoginDialog(Context mContext) {
        final AlertDialog dialog = new AlertDialog.Builder(mContext, R.style.custom_dialog).create();
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
        Window window = dialog.getWindow();
        window.setContentView(R.layout.public_no_login_dialog);

        TextView title = (TextView) window.findViewById(R.id.public_title_no_login);
        TextView content = (TextView) window.findViewById(R.id.public_content_no_login);
        TextView cancel = (TextView) window.findViewById(R.id.public_cancel_no_login);
        TextView submit = (TextView) window.findViewById(R.id.public_submit_no_login);


        title.setText("您还未登录");
        content.setText("请先登录再进行操作");
        cancel.setText("再看看");
        submit.setText("去登录");
        content.setGravity(Gravity.CENTER);


        //如果reportContent内容太多了的话，我们需要让其滚动起来，
        //具体可以查看SDK中android.text.method了解更多，代码如下：
        content.setMovementMethod(ScrollingMovementMethod.getInstance());

        cancel.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                dialog.dismiss();
            }
        });

        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                dialog.dismiss();

            }
        });
    }

    public static void openFileDialog(Context mContext,View.OnClickListener confirm) {
        final AlertDialog dialog = new AlertDialog.Builder(mContext, R.style.custom_dialog).create();
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
        Window window = dialog.getWindow();
        window.setContentView(R.layout.public_no_login_dialog);

        TextView title = (TextView) window.findViewById(R.id.public_title_no_login);
        TextView content = (TextView) window.findViewById(R.id.public_content_no_login);
        TextView cancel = (TextView) window.findViewById(R.id.public_cancel_no_login);
        TextView submit = (TextView) window.findViewById(R.id.public_submit_no_login);


        title.setText("提示");
        content.setText("文件已下载，是否打开？");
        cancel.setText("取消");
        submit.setText("打开");
        content.setGravity(Gravity.CENTER);


        //如果reportContent内容太多了的话，我们需要让其滚动起来，
        //具体可以查看SDK中android.text.method了解更多，代码如下：
        content.setMovementMethod(ScrollingMovementMethod.getInstance());

        cancel.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                dialog.dismiss();
            }
        });

        submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                dialog.dismiss();
                confirm.onClick(arg0);
            }
        });
    }


}
